<extend name="Common@Base/layout"/>
<block name="body">
    <div class="main-content main-pagebar-content">
        <div class="container-fluid">
            <div class="row">
                <div class="col-sm-12">
                    <h3 class="mod-title">
                            <span class="t">
                                {$task.title}
                            </span>
                        <span class="pull-right">
                                 分值:{$task.total_score}
                            </span>
                    </h3>
                    <div class="panel panel-default">
                        <form id="paging_form" name="paging_form" method="post" action="/task/score/detail">
                            <input name="taskid" type="hidden" value="{$task.id}"/>
                            <div class="panel-body panel-body-up-table">
                                <div class="search-panel">
                                    <div class="search">
                                        <div class="dropdown btn-group">
                                            <a class="btn btn-default dropdown-toggle" data-toggle="dropdown">
                                                <span id="search_status_name" class="option-name">全部</span> <i class="fa fa-angle-down"></i></a>
                                            <ul class="dropdown-menu dropdown-option-menu">
                                                <li><a data-value="" role="button">全部</a></li>
                                                <li><a data-value="0,1" role="button">未报</a></li>
                                                <li><a data-value="2" role="button">已报</a></li>
                                                <li><a data-value="3" role="button">已评</a></li>
                                                <li><a data-value="4" role="button">已审</a></li>
                                            </ul>
                                            <input id="search_status" name="search_status" class="option-value filter-item-value" type="hidden"
                                                   value="{$_page->parameter['search_status']}">
                                        </div>
                                        <div class="dropdown btn-group">
                                            <a class="btn btn-default dropdown-toggle" data-toggle="dropdown">
                                                <span id="rank_name" class="option-name">全部</span> <i class="fa fa-angle-down"></i>
                                            </a>
                                            <ul class="dropdown-menu dropdown-option-menu">
                                                <li><a data-value="" role="button">全部</a></li>
                                                <li><a data-value="1" role="button">省级</a></li>
                                                <li><a data-value="2" role="button">市级</a></li>
                                                <li><a data-value="3" role="button">区级</a></li>
                                            </ul>
                                            <input id="rank" name="rank" class="option-value filter-item-value" type="hidden" value="{$_page->parameter['rank']}">
                                        </div>

                                        <div class="dropdown btn-group">
                                            <a class="btn btn-default dropdown-toggle" data-toggle="dropdown">
                                                <span id="attribute_name" class="option-name">全部</span> <i class="fa fa-angle-down"></i>
                                            </a>
                                            <ul class="dropdown-menu dropdown-option-menu">
                                                <li><a data-value="" role="button">全部</a></li>
                                                <li><a data-value="1" role="button">单位</a></li>
                                                <li><a data-value="2" role="button">学校</a></li>
                                                <li><a data-value="3" role="button">社区</a></li>
                                            </ul>
                                            <input id="attribute" name="attribute" class="option-value filter-item-value" type="hidden" value="{$_page->parameter['attribute']}">
                                        </div>
                                        <div class="btn-group">
                                            <input name="search_key" type="text" class="form-control" value="{$_page->parameter['search_key']|urldecode}"
                                                   placeholder="请输入标题">
                                        </div>
                                        <div class="btn-group">
                                            <button type="submit">搜索</button>
                                        </div>
                                    </div>

                                </div>

                            </div>
                        </form>
                        <form id="assess_form" name="assess_form" method="post" action="/task/score/assess">
                            <input name="task_type" type="hidden" value="{$task.task_type}"/>
                            <div class="table-responsive">
                                <table class="table-check table-link-hover table table-striped table-bordered table-hover">
                                    <thead>
                                    <tr>
                                        <th>上报单位</th>
                                        <th class="text-center">上报内容</th>
                                        <th class="text-center" style="width:20%">相关附件</th>
                                        <th class="text-center" style="width:8%">状态</th>
                                        <th style="width:6%">级别</th>
                                        <th style="width:6%">属性</th>
                                        <th class="text-center">备注</th>
                                        <th class="text-right">评分</th>
                                    </tr>
                                    </thead>
                                    <tbody>
                                    <volist name="user_task_list" id="user_task">
                                        <tr data-vid="{$user_task.id}">
                                            <td>{$user_task.user_id|fc_get_user_account}</td>
                                            <td>
                                                <div class="truncate-t" title="{$user_task.report_content}">{$user_task.report_content}
                                                </div></td>
                                            <td>
                                                <volist name="user_task['user_task_annex']" id="annex">
                                                    <a style="padding-right:8px" target="_blank" href="{$Think.config.UPLOAD_IMAGE_URL}{$annex.annex_path}">
                                                        {$annex.annex_name}
                                                    </a><br/>
                                                </volist>
                                            </td>
                                            <td class="text-center">
                                                {$user_task.status|fc_get_config_value="DOC_STATUS"}
                                            </td>
                                            <td>{$user_task.rank|fc_get_config_value="TASK_RANK"}</td>
                                            <td>{$user_task.attribute|fc_get_config_value="USER_ATTRIBUTE"}</td>
                                            <td>
                                                <if condition="($user_task.status eq 2) OR $user_task.status eq 3">
                                                    <input name="remark[]" type="text" class="form-control" value="{$user_task.remark}">
                                                    <else/>
                                                    {$user_task.remark}
                                                </if>
                                            </td>
                                            <td class="td-action">
                                                <if condition="($user_task.status eq 2) OR $user_task.status eq 3">
                                                    <if condition="$user_task.task_type eq 0">
                                                        <div class="btn-group" data-total_score="{$user_task.total_score}">
                                                            <button type="button" data-toggle="modal" data-target="#edit_back_reason"  class="btn btn-default" action-type="back">回退</button>
                                                            <button type="button" class="btn btn-default" data-percent="60">&nbsp60%</button>
                                                            <button type="button" class="btn btn-default" data-percent="80">&nbsp80%</button>
                                                            <button type="button" class="btn btn-default" data-percent="100">100%</button>
                                                        </div>
                                                    </if>
                                                    <div class="btn-group">

                                                        <input name="user_task_id[]" type="hidden" value="{$user_task.id}">
                                                        <if condition="$user_task.status eq 2">
                                                            <input name="amount_score[]" type="text" style="width:60px" class="form-control"
                                                                   value="{$user_task['total_score']*60/100|round}"
                                                                   placeholder=" 得分">
                                                            <else/>
                                                            <input name="amount_score[]" type="text" style="width:60px" class="form-control" value="{$user_task.amount_score}"
                                                                   placeholder=" 得分">
                                                        </if>
                                                    </div>
                                                    <else/>
                                                    <div class="btn-group">
                                                        {$user_task.amount_score}
                                                    </div>
                                                </if>
                                            </td>
                                        </tr>
                                    </volist>
                                    </tbody>
                                </table>
                                <input class="checked-item" type="hidden">
                            </div>
                        </form>
                    </div>
                    <div class="body-footer pull-right">
                        <button type="button" class="btn btn-default" onclick="location.href='/task/score/index?task_type={$task.task_type}';">返 回</button>
                        <button type="button" class="btn btn-primary" action-type="assess">提交评分</button>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <include file="back"/>
    <script>
        $(document).ready(function () {
            $('#nav-task{$task_type}').addClass("active");
            var vx = $("#search_status").val();
            if (vx != "") {
                $("#search_status").prev().find('a').each(function () {
                    var $this = $(this);
                    if ($this.data('value') == vx) {
                        $("#search_status_name").text($this.text());
                    }
                });
            }
            vx = $("#rank").val();
            if (vx != "") {
                $("#rank").prev().find('a').each(function () {
                    var $this = $(this);
                    if ($this.data('value') == vx) {
                        $("#rank_name").text($this.text());
                    }
                });
            }

            vx = $("#attribute").val();
            if (vx != "") {
                $("#attribute").prev().find('a').each(function () {
                    var $this = $(this);
                    if ($this.data('value') == vx) {
                        $("#attribute_name").text($this.text());
                    }
                });
            }
            $('button[data-percent]').click(function () {
                var $this = $(this);
                var input = $this.parent().next().find('input[placeholder]');
                var s = Math.round($this.parent().data('total_score') * $this.data('percent') / 100);
                input.val(s);
            });

            $('button[action-type="assess"]').click(function () {
                var $tr = $(this).parent().parent();
                alertify.confirm("确定操作？", function (e) {
                    $('#assess_form').submit();
                });
            });

            // $('button[action-type="back"]').click(function () {
            //     var $this = $(this);
            //     var $tr = $this.parent().parent().parent();
            //     var action_type = $this.attr('action-type');
            //     var msg = "确定回退？";
            //
            //     alertify.confirm(msg, function (e) {
            //         var postdata = 'user_task_id=' + $tr.data('vid') + "&action_type=" + action_type;

                    // $.post($('#review_form').attr('action'), postdata, function (data) {
                    //     if (data === "0") {
                    //         $tr.remove()
                    //     }
                    // }).error(function (msg, url, line) {
                    //     alert(msg.responseText);
                    // });
                // });
        });
    </script>
</block>